<?php
showtips($touclicklang['tcmsg0015'],'tips1',true,$touclicklang['tipsTitle4']);

if(submitcheck('delsubmit')) {
	$ids = $_POST['ids'];
	
	if($ids != "" && $_POST['mk'] != ""){
		
		$idstr = "";
		foreach ($ids as $id){
			$idstr .= $id."-";
		}
		$idstr = substr($idstr, 0, -1);
		
		$data = array(
				"b" => $touclickB,
				"z" => $touclickZ,
				"v" => $touclickV,
				"d" => $touclickD,
				"pf" => $touclickPF,
				'cs' => $touclickCS,
				"op" => '1003',
				"do" => $_POST['mk'],
				"ids" => $idstr
				);
		$resRep = touclick_request("http://api.touclick.com/captchadiy.touclick", $data, 80);
		if($resRep['content'] == "alert"){
			cpmsg("{$touclicklang['alert']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
		}elseif($resRep['content'] == "alerts"){
			cpmsg("{$touclicklang['alerts']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
		}elseif($resRep['content'] == "wait"){
			cpmsg("{$touclicklang['wait']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
		}elseif($resRep['content'] == "live"){
			cpmsg("{$touclicklang['live']}", "action=plugins&cp=$cp&pmod=activate&operation=$operation&do=$do", 'error');
		}elseif($resRep['content'] == "vip"){
			cpmsg("{$touclicklang['vip']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
		}elseif($resRep['content'] == "yes"){
			cpmsg("{$touclicklang['yes']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'succeed');
		}else{
			cpmsg("{$touclicklang['others']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
		}
	}
}




$report=array();

$page= isset($_GET['page'])?$_GET['page']:1;
$pagesize = 5;
$pagelen = 3;

$sign = $_GET['signType'];

$data= array(
		"b" => $touclickB,
		"z" => $touclickZ,
		"v" => $touclickV,
		"d" => $touclickD,
		"pf" => $touclickPF,
		"op" => "1002",
		'cs' => $touclickCS,
		'sl' => $pagesize * ($page -1 ),
		'ps' => $pagesize,
);

$resRep = touclick_request("http://api.touclick.com/captchadiy.touclick", $data, 80);
if($resRep['content'] == "alert"){
	cpmsg("{$touclicklang['alert']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
}elseif($resRep['content'] == "alerts"){
	cpmsg("{$touclicklang['alerts']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
}elseif($resRep['content'] == "wait"){
	cpmsg("{$touclicklang['wait']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
}elseif($resRep['content'] == "live"){
	cpmsg("{$touclicklang['live']}", "action=plugins&cp=$cp&pmod=activate&operation=$operation&do=$do", 'error');
}elseif($resRep['content'] == "vip"){
	cpmsg("{$touclicklang['vip']}", "action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", 'error');
}
//cpmsg($resRep['content']);
$report = $tcJSON->decode($resRep['content'], true);
//  print_r($report);
$phpfile = "admin.php?action=plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do&signType=$sign";
$pageNum = $report[count];
$getpageinfo = page($page, $pageNum, $phpfile, $pagesize, $pagelen);

showformheader("plugins&cp=$cp&pmod=managediy&operation=$operation&do=$do", "",'delform','post');
	showtableheader("{$touclicklang['diylist']}");
	echo "<tr class='header'><th></th><th>{$touclicklang['captchalist']}</th><th>{$touclicklang['diybg']}</th><th>{$touclicklang['printword']}</th><th>{$touclicklang['clickword']}</th><th>{$touclicklang['printpic']}</th><th>{$touclicklang['pictransparent']}</th><th>{$touclicklang['tipword']}</th><th>{$touclicklang['isopen']}</th><th>{$touclicklang['ispass']}</th></tr>";
	foreach($report[ads] as $detailModel){
		$tclass = $detailModel[tclass] == 1? "{$touclicklang['picword']}": "{$touclicklang['picpic']}";
		
		$pword = $detailModel[pword]== null?"-" :base64_decode($detailModel[pword]);
		$cword = $detailModel[cword]== null?"-" :base64_decode($detailModel[cword]);
		
		$transparent = $detailModel[transparent]== null?"-" :$detailModel[transparent];
		$tword = $detailModel[tword]== null?"-" :base64_decode($detailModel[tword]);
		$smallPic = $detailModel[smallPic]== null?"-" :"<img src='".$detailModel[smallPic]."'/>";
		$ispass = $detailModel[isPass] == 1? "{$touclicklang['passed']}":( base64_decode($detailModel[adminnote]) == "" ? $touclicklang['passing'] : base64_decode($detailModel[adminnote]) );
		$isEnable = $detailModel[isEnable] == 1? "{$touclicklang['open']}":"{$touclicklang['stop']}";
		$w = 356 * (60/179);
		echo "<tr class='hover'><td class='td25'><input class='checkbox' type='checkbox' value='{$detailModel[adID]}' name='ids[]'></td><td>{$tclass}</td><td><img width='{$w}' height='60px' src='{$detailModel[bgImage]}'/></td><td>{$pword}</td><td>{$cword}</td><td>{$smallPic}</td><td>{$transparent}</td><td>{$tword}</td><td>{$isEnable}</td><td>{$ispass}</td></tr>";
	}
	echo <<<EOF
<tr>
<td colspan=3>
<div class="fixsel">
<input id="chkall" class="checkbox" type="checkbox" onclick="checkAll('prefix', this.form, 'ids')" name="chkall">
<label for="chkall">{$touclicklang['selectall']}</label>
<input id="mkunenable" class="radio" type="radio" value="stop" checked name="mk">
<label for="mkunenable">{$touclicklang['stop']}</label>
<input id="mkenable" class="radio" type="radio" value="open" name="mk">
<label for="mkenable">{$touclicklang['open']}</label>
<input id="mkdelete" class="radio" type="radio" value="move" name="mk">
<label for="mkdelete">{$touclicklang['move']}</label>
<input class="btn" type="submit" value="{$touclicklang['submit']}" id='delsubmit' name="delsubmit">
</div>
</td>
EOF;
	echo "<td colspan=7 align=right>".$getpageinfo['pagecode']."</td></tr>";
	showtablefooter();
showformfooter();


echo "</div>";


